home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 011a / pscrn43.zip / PS_DEMO.BAS < prev    next >
BASIC Source File  |  1991-11-14  |  25KB  |  609 lines

  1. '┌───────────────────────────────────────────────────────────────────────────┐
  2. '│ P-Screen Demo                             QuickBASIC 4.x -OR- PDS 7 Only  │
  3. '├───────────────────────────────────────────────────────────────────────────┤
  4. '│ Demo program included with P-Screen (Pro~Formance Screen Design).         │
  5. '│                                                                           │
  6. '│ Compatibility:   QuickBasic 4.x only  -OR- PDS 7                          │
  7. '│                                                                           │
  8. '│    3 Purposes:   Demonstrate how to:                                      │
  9. '│                     1.  Display screens stored in a Library.              │
  10. '│                         - Press <H>elp to view a Help Screen.  Notice the │
  11. '│                           small amount of code needed to display a screen.│
  12. '│                                                                           │
  13. '│                     2.  Display a directory of Library Screen names.      │
  14. '│                                                                           │
  15. '│                     3.  Load several screens (Menus) at once, then later  │
  16. '│                         display 'em on demand.                            │
  17. '│                                                                           │
  18. '│        To run:   Run QB or QBX, loading a Quick Library that contains:    │
  19. '│                                                                           │
  20. '│                  - rsLoadScrn.obj     -rsLodBin.obj      -rsCompRest.obj  │
  21. '│                                                                           │
  22. '│                  For QuickBASIC 4.5:                                      │
  23. '│                                                                           │
  24. '│                         QB ps_demo /l ps_demo  (note underline characters)│
  25. '│                                                                           │
  26. '│                  For PDS 7:                                               │
  27. '│                                                                           │
  28. '│                         QBX ps_demo /l bc7demo (note underline character) │
  29. '│                                                                           │
  30. '│       History:   1st cut 12/88                                            │
  31. '│                  p-screen menus 4/90                                      │
  32. '│                  rsWindow added 8/90                                      │
  33. '│                  ASM screen demo added 9/91                               │
  34. '└───────────────────────────────────────────── (C) 1988-1991 R.W. Smetana  ─┘
  35.  
  36. DEFINT A-Z          '... Integers ONLY.  If not, called routines will crash.
  37.  
  38. '................. .................  ................. .................
  39.  
  40. '... Declare SUBs and FUNCTIONs in this module.
  41.  
  42. DECLARE SUB LoadMenus (MenuDemo%(), Menu.ErrCode%)
  43. DECLARE SUB ASM.Screens ()
  44. DECLARE FUNCTION Display.Screen (LibName$, ScreenName$, IsBrightOn%)
  45. DECLARE SUB Display.Directory (LibraryName$)
  46.  
  47. '... Declare procedures included in PS-Demo.Qlb
  48.  
  49. DECLARE SUB rsLoadScrn (Array%(), LibraryName$, FileName$, Desc$, TopRow%, LeftCol%, BotRow%, RhtCol%, x%, ErrCode%)
  50. DECLARE SUB rsCompRest (TopRow%, BotRow%, SEG Array%)
  51. DECLARE SUB CompRestPLUS (Top, Lft, Bot, Rht, SEG Array%)
  52.  
  53.  
  54.  
  55. '...Caution:  Use rsCompRest ONLY for full-width screens.  Registered
  56. '   users receive CompRestPlus which can display ANY SIZE screens.
  57. '   P-Screen COMPRESSES screens.  Only our display routines can display 'em.
  58. '   But you can use our screen-display routines to restore ANY screen,
  59. '   compressed or normal.  And we use the same routines to display ASM screens.
  60.  
  61.  
  62. CONST True = -1: False = NOT True
  63.  
  64. CONST LibraryName$ = "P-SCREEN"         '... Display all screens from
  65.                                         '    P-Screen.Psl
  66.  
  67. TYPE ScrLib                             '... TYPE to read Names/Descriptions
  68.     ScrName AS STRING * 8               '    of screens in a Library
  69.     Description AS STRING * 15
  70.     IgnoreMe AS STRING * 14
  71. END TYPE
  72. DIM SHARED ScreenLib AS ScrLib
  73.  
  74. '................. .................  ................. .................
  75.  
  76. '... 1st, see if "P-Screen.Psl" exists.  If not, stop.
  77.  
  78.     ON ERROR GOTO CantFindLibrary   '... Demo aborts if P-Screen.Psl isn't found.
  79.  
  80.     CLOSE : OPEN LibraryName$ + ".Psl" FOR INPUT AS #1  '... Just checking.  Your
  81.     CLOSE                                           '    programs must ensure
  82.                                                     '    Libraries exist BEFORE
  83.                                                     '    calling our routines.
  84.  
  85. REDIM MenuDemo%(1)                                  '... Load ALL P-Screen-style
  86. CALL LoadMenus(MenuDemo%(), Menu.ErrCode)           '    menus into one array.
  87.                                                     '    Press "M" at the menu
  88.                                                     '    to see the results.
  89.  
  90. '................. .................  ................. .................
  91. '... Main Menu
  92. '................. .................  ................. .................
  93.   
  94.    LOCATE , , 1                           '... turn on the cursor
  95.  
  96.    DO UNTIL Option$ = CHR$(27)            '... press ESCAPE to exit this demo
  97.  
  98.       GOSUB PrintMenu                     '... display our Main Menu
  99.  
  100.       DO: Option$ = UCASE$(INKEY$): LOOP UNTIL LEN(Option$)
  101.  
  102.       Option$ = UCASE$(Option$)
  103.  
  104.       CLS
  105.  
  106.       SELECT CASE Option$
  107.          CASE "H": GOSUB Help
  108.          CASE "D": Display.Directory LibraryName$
  109.                    GOSUB Pause
  110.          CASE "M": GOSUB MenuDemo
  111.          CASE "A": ASM.Screens
  112.       END SELECT
  113.  
  114.    LOOP
  115.  
  116.    PRINT "Thank you for trying P-Screen ..... <rws>"
  117.  
  118. END
  119. '................. .................  ................. .................
  120. Help:    '... demonstrate how to Display Library Screen/interpret ErrCode
  121. '................. .................  ................. .................
  122.  
  123.     ScreenName$ = "QUIKREF1"            '... P-Screen's Quick Reference Guide
  124.  
  125. '... If we got this far, LibraryName$ + ".Psl" is available on the
  126. '    "current" drive.  So, display ScreenName$.
  127. '................. .................  ................. .................
  128.  
  129.    '... NOTE:  Screen names are stored in Upper Case in screen libraries.
  130.    '    So we pass "UCase$(ScreenName$) to ensure we find it.
  131.   
  132.    '... Also note how we use the function Display.Screen (in this case
  133.    '    in a Select Case statement).
  134.  
  135.    SELECT CASE Display.Screen(LibraryName$, UCASE$(ScreenName$), IsBrightOn%)
  136.  
  137.      CASE 0                                 '... No error
  138.         GOSUB ShowInfo                      '... for your information
  139.     
  140.      CASE -99                               '... screen NOT in Library
  141.         PRINT TAB(20); "<"; ScreenName$; ">  was NOT in "; LibraryName$; ".Psl";
  142.     
  143.      CASE -88                               '... error loading it (probably -1)
  144.         PRINT TAB(20); "<Too little Memory> to display screens.";
  145.     
  146.      CASE ELSE
  147.        PRINT TAB(20); " An error occurred loading "; ScreenName$;
  148.    END SELECT
  149.  
  150.  
  151.     GOSUB Pause2                    '... pause
  152.  
  153. RETURN
  154. '................. .................  ................. .................
  155. ShowInfo:           '... display info returned by rsLoadScrn
  156. '................. .................  ................. .................
  157.       
  158.     CALL rsWindow(" Press a key . . . ", 32, 7, 12, 16, 67, 2, 112, True)
  159.  
  160.     COLOR 0, 7
  161.     LOCATE 9, 15:   PRINT "This shows how to display full-screen Help Screens."
  162.     LOCATE 11, 20:  PRINT "This one is P-Screen's summary of commands."
  163.     LOCATE , 21:    PRINT "We displayed this from a screen library."
  164.     LOCATE 14, 14:  PRINT "We used the Display.Screen function to display this.";
  165.     COLOR 7, 0
  166.  
  167. RETURN
  168.  
  169. '................. .................  ................. .................
  170. Pause:         '...print a message and pause
  171. '................. .................  ................. .................
  172.     LOCATE 23, 20: PRINT SPC(12); "Press a key . . ."; SPC(15);
  173.  
  174. Pause2:        '...just pause
  175.  
  176.     DO UNTIL LEN(INKEY$): LOOP
  177.  
  178. RETURN
  179. '................. .................  ................. .................
  180. MenuDemo:   '... Demonstrate displaying screens from an array.
  181. '................. .................  ................. .................
  182.         'Uses CompRestPlus (Call CompRestPlus ...) to display ANY
  183.         'size full screen or sub-screen (registered users only).
  184.  
  185.         'The array MenuDemo%() was loaded with screens from P-Screen.Psl
  186.         'when you first ran this demo --- Call LoadMenus (MenuDemo%(), Menu.ErrCode).
  187.         'Loading menus from a screen library into an Integer array
  188.         'saves you a few '000 bytes of valuable string/data space.
  189.  
  190. 'NOTE:  If strange things happen when you run this, P-Screen.Psl, or
  191. '       this demo, were probably tampered with.  The Row/Column and
  192. '       MenuDemo% offsets BELOW may no longer be correct.  If not,
  193. '       you'll get some bizzare looking screens.
  194. '............... .................  ................. .................
  195.  
  196.     IF Menu.ErrCode THEN          '... error occurred loading screens
  197.         PRINT TAB(12); "Error occurred loading screens earlier.  Can't do demo."
  198.         BEEP: GOSUB Pause2: RETURN
  199.     END IF
  200.  
  201. '--- We're only interested in "OurKeys$" -- certain (Alt-/Cursor) keys : : :
  202.  
  203. '... Alt-key scan codes for Alt- : : :
  204.     'F (!), D (" "), B (0), E (Chr$(18)),  O (24), H (#)
  205.  
  206. '... Scan codes for Right/Left Cursor keys ==>> M/K.  Escape = Chr$(27)
  207. '    We want these in a certain order.  Thus the gyrations below.
  208.  
  209.      OurKeys$ = "! 0" + CHR$(18) + CHR$(24) + "#MK"
  210.  
  211.      Waitfor! = 1                                   '... length of pause (see below)
  212.      Start = 0                                      '... For Left/Right Cursor
  213.  
  214.      '... First, blast all our menus up
  215.  
  216.      CALL CompRestPLUS(1, 1, 1, 80, SEG MenuDemo%(MenuDemo%(1))) '  see note below re: Offsets
  217.  
  218.      d$ = " "
  219.      FOR x = 1 TO LEN(OurKeys$)
  220.          LSET d$ = MID$(OurKeys$, x, 1): GOSUB DisplayMenu
  221.      NEXT
  222.      GOSUB Pause
  223.  
  224.      CALL rsWindow(Blank$, Zero, 18, 1, 25, 80, 177, 11, True)
  225.      LOCATE 19, 3: PRINT "These menus are displayed from an INTEGER array, NOT disk.  This demo shows"
  226.      LOCATE , 3:   PRINT "how you can load many screens as programs start, then display them later."
  227.      LOCATE , 3:   PRINT "See 'Performance Hints' in your manual. Screens displayed with CompRestPlus."
  228.      LOCATE 23, 21: PRINT " Pausing"; Waitfor!; "second(s) before clearing menus ";
  229.  
  230.      LOCATE 25, 6: PRINT "Press:  "; CHR$(27); "/"; CHR$(26); " cursor keys,   or    Alt- F, D, B, E, O, H     <Esc> = Exit";
  231.  
  232.  
  233.      DO                                             '... Outer Loop
  234.  
  235.          '... use rsWindow again, this time to "clear" some of the screen
  236.          CALL rsWindow(Blank$, 32, 2, 1, 17, 80, 32, 7, True)
  237.  
  238.          '... use it again to "paint" our top menu line (restore color)
  239.          CALL rsWindow(Blank$, 32, 1, 1, 1, 80, 255, 112, True)
  240.  
  241.          '>>>> Note the Pause between screens at the end of this loop <<<<
  242.  
  243.  
  244.             DO                                         '... get a key
  245.  
  246.               d$ = INKEY$
  247.  
  248.             LOOP UNTIL (LEN(d$) = 2 AND INSTR(OurKeys$, RIGHT$(d$, 1))) OR d$ = CHR$(27)
  249.  
  250.  
  251.             IF d$ = CHR$(27) THEN EXIT DO   '... exit Outer Loop on Esc
  252.  
  253.             d$ = RIGHT$(d$, 1)              '... It's Extended, take 2nd key/Strip Chr$(0)
  254.  
  255.             IF INSTR("MK", d$) THEN         '... if Right/Left Cursor then...
  256.                IF d$ = "M" THEN     'right cursor
  257.                   Start = Start + 1: IF Start > 6 THEN Start = 1
  258.                ELSE                 'left cursor
  259.                   Start = Start - 1: IF Start < 1 THEN Start = 6
  260.                END IF
  261.  
  262.                '... turn d$ into it's Alt-key equivalent based on Start
  263.                d$ = MID$(OurKeys$, Start, 1)
  264.  
  265.             END IF
  266.  
  267.             GOSUB DisplayMenu
  268.  
  269.  
  270.          '--- Pause briefly before we refresh the screen.  To change the length
  271.          '    of the pause, change the value of WaitFor! above the Main Loop.
  272.  
  273.          GOSUB MenuPause
  274.  
  275.      LOOP
  276.  
  277. RETURN
  278. '................. .................  ................. .................
  279. MenuPause:
  280. '................. .................  ................. .................
  281.     
  282.      x! = TIMER: DO UNTIL TIMER > x! + Waitfor!: LOOP
  283.  
  284. RETURN
  285. '................. .................  ................. .................
  286. DisplayMenu:
  287. '................. .................  ................. .................
  288.  
  289.     SELECT CASE d$                  '... NOTE:  We reserved the 1st 10
  290.                                     '    elements in MenuDemo%() to store
  291.                                     '    the offset into MenuDemo% where
  292.                                     '    each screen BEGINS.
  293.                                     '    See Sub LoadMenus for details.
  294.  
  295.       CASE "!"          '... Alt-F (File)
  296.           CALL CompRestPLUS(1, 2, 15, 27, SEG MenuDemo%(MenuDemo%(2)))
  297.  
  298.       CASE " "          '... Alt-D (Draw)
  299.           CALL CompRestPLUS(1, 11, 8, 34, SEG MenuDemo%(MenuDemo%(3)))
  300.  
  301.       CASE "0"          '... Alt-B (Block)
  302.           CALL CompRestPLUS(1, 20, 17, 43, SEG MenuDemo%(MenuDemo%(4)))
  303.  
  304.       CASE CHR$(18)     '... Alt-E (Edit)
  305.           CALL CompRestPLUS(1, 30, 9, 50, SEG MenuDemo%(MenuDemo%(5)))
  306.  
  307.       CASE CHR$(24)     '... Alt-O (Options)
  308.           CALL CompRestPLUS(1, 39, 14, 63, SEG MenuDemo%(MenuDemo%(6)))
  309.  
  310.       CASE "#"          '... Alt-H (Help)
  311.           CALL CompRestPLUS(1, 51, 12, 75, SEG MenuDemo%(MenuDemo%(7)))
  312.  
  313.     END SELECT
  314.  
  315. RETURN
  316. '................. .................  ................. .................
  317. CantFindLibrary:    '... couldn't find LibraryName$ + ".Psl"
  318. '................. .................  ................. .................
  319.  
  320.     OurErr = ERR
  321.     CLS : CLOSE
  322.     PRINT TAB(18); "Can't find "; LibraryName$ + ".Psl.  Press a key . . .";
  323.     BEEP: GOSUB Pause2: END
  324.  
  325.  
  326. '................. .................  ................. .................
  327. PrintMenu:
  328. '................. .................  ................. .................
  329.  
  330.    '... First, clear the screen, filling it with some character.
  331.    '    This is the "fill screen" option of rsWindow
  332.  
  333.    CALL rsWindow(" P-Screen Demo ", 176, 1, 1, 25, 80, 2, 15, True)
  334.  
  335.    '... The next 6 lines aren't really necessary,
  336.    '    but rsWindow is kind of handy.
  337.  
  338.    '--- Draw a VERTICAL line  (no For...Next loop needed) !!
  339.    CALL rsWindow(Blank$, 177, 2, 80, 24, 80, 177, 2, True)
  340.    '--- add some arrows
  341.    CALL rsWindow(Blank$, Zero, 2, 80, 2, 80, 24, 112, True)
  342.    CALL rsWindow(Blank$, Zero, 24, 80, 24, 80, 25, 112, True)
  343.  
  344.    '--- Draw a HORIZONTAL line
  345.    CALL rsWindow(Blank$, Zero, 25, 2, 25, 79, 177, 2, True)
  346.    '--- add some arrows
  347.    CALL rsWindow(Blank$, Zero, 25, 3, 25, 3, 27, 112, True)
  348.    CALL rsWindow(Blank$, Zero, 25, 78, 25, 78, 26, 112, True)
  349.  
  350.  
  351.    '... Now display our menu options.
  352.  
  353.    a$ = "Do you want Help, a Directory or a Menu Demo?"
  354.    b$ = "Press:  <H>elp, <D>irectory, <M>enu  ──"
  355.    c$ = "Esc> = Exit this Demo"
  356.  
  357.    '... use rsWindow to "shadow" the next one  (rsWindow's "paint" option)
  358.    CALL rsWindow(Blank$, 32, 9, 12, 19, 72, 255, 8, True)
  359.  
  360.    '... Now create our Window
  361.    CALL rsWindow(" Choose a demo of one of these: ", 32, 8, 10, 18, 70, 1, 112, True)
  362.    CALL rsWindow("", 196, 14, 11, 14, 69, 196, 112, True)
  363.  
  364.    COLOR 0, 7
  365.    LOCATE 10, 18: PRINT "A demo of ASM screens, a help screen demo,"
  366.    LOCATE 12, 18:   PRINT "a screen library directory, or a menu demo."
  367.    LOCATE 18, 28: PRINT "<Esc> = Exit this Demo"
  368.    LOCATE 16, 18:   PRINT "Press:  <A>sm, <H>elp, <D>irectory, <M>enu  ──";
  369.  
  370.    a$ = "": b$ = "": c$ = ""
  371.    COLOR 7, 0
  372.  
  373. RETURN
  374.  
  375. '
  376. SUB ASM.Screens
  377. '
  378.  
  379.     '... Some screens we're about to display have bright backgrounds.  So call
  380.     '    BrightBG to enable these (these will blink on Mono or Herc monitors).
  381.  
  382.     CALL BrightBG(1)
  383.  
  384.     CLS
  385.     LOCATE 20, 2: PRINT "These are ASM screens:  assembled, then displayed with a simple CALL MyScreen."
  386.     LOCATE 22, 10: PRINT "Press any key to quit.  Number of screens displayed:  ";
  387.    
  388.     '... let's time this
  389.     Start! = TIMER
  390.    
  391.     MaxNumberScreens = 11
  392.  
  393.     DO UNTIL LEN(INKEY$)                     '... press a key to exit this
  394.  
  395.       WhichScreen = WhichScreen + 1
  396.       IF WhichScreen > MaxNumberScreens THEN WhichScreen = 1
  397.  
  398.       SELECT CASE WhichScreen
  399.  
  400.          CASE 1: CALL pscrTop1
  401.          CASE 2: CALL pscrFile
  402.          CASE 3: CALL pscrDraw
  403.          CASE 4: CALL pscrBlok
  404.          CASE 5: CALL pscrEdit
  405.          CASE 6: CALL pscrOptn
  406.          CASE 7: CALL pscrHelp
  407.          CASE 8: CALL Box1
  408.          CASE 9: CALL Box2
  409.         CASE 10: CALL Box3
  410.         CASE 11: CALL Box4
  411.  
  412.       END SELECT
  413.      
  414.       x& = x& + 1: LOCATE 22, 64: PRINT x&;
  415.       
  416.     LOOP
  417.    
  418.     NumSeconds! = TIMER - Start!: IF NumSeconds! < 1 THEN NumSeconds! = 1
  419.  
  420.     LOCATE 22, 1: PRINT x&; "screens in"; NumSeconds!; "seconds ("; CINT(x& / NumSeconds!); "screens per second! ).  Press a key.";
  421.     LOCATE 24, 1: PRINT "This also shows 'bright background' screens.  Run again if you didn't see them.";
  422.  
  423.     WHILE INKEY$ = "": WEND
  424.  
  425.     '... We no longer need BrightBG.  Turn it off.
  426.  
  427.     CALL BrightBG(0)
  428.  
  429.  
  430. END SUB
  431.  
  432. '
  433. SUB Display.Directory (LibraryName$)
  434. '
  435.    FileNum = FREEFILE
  436.    OPEN Path$ + LibraryName$ + ".PSL" FOR RANDOM AS #FileNum LEN = LEN(ScreenLib)
  437.  
  438.    PRINT TAB(26); "Screens Stored in "; LibraryName$; ".Psl": PRINT
  439.    PRINT TAB(7); "Name"; TAB(17); "Description"; TAB(49); "Name"; TAB(59); "Description"
  440.    PRINT
  441.                                                    '... skip header record and
  442.    FOR x = 2 TO 101                                '    start at record #2
  443.        GET #FileNum, x, ScreenLib                  '... using TYPE format
  444.  
  445.        a$ = LTRIM$(RTRIM$(ScreenLib.ScrName))      '... strip blanks
  446.        IF a$ = "" THEN EXIT FOR                    '1st blank means "all done"
  447.  
  448.        PRINT USING "  ##. "; x - 1;
  449.        PRINT LEFT$(a$ + SPACE$(10), 10); ScreenLib.Description,
  450.    NEXT
  451.  
  452.    CLOSE
  453.  
  454.  
  455. END SUB
  456.  
  457. '
  458. '-------------------------------------------------------------
  459. '
  460. FUNCTION Display.Screen (LibName$, ScreenName$, IsBrightOn%)
  461. '
  462. '           Feel free to merge this into your own programs.
  463. '
  464. ' Purpose:  Display a screen it it's original location.
  465. ' Returns:  Display.Screen (an integer)
  466. '           - If zero on return, everything went fine.
  467. '           - If NEGATIVE, an error occurred:
  468. '              -88   Not enough memory to allocate screen array
  469. '              -99   The Screen Library wasn't found
  470. '        
  471. '-------------------------------------------------------------
  472.  
  473.   '... assume NO error
  474.   Display.Screen = 0
  475.  
  476.  
  477.   '... Test to see if there's enough memory for an array big
  478.   '    enough for your largest screen.
  479.  
  480.   ArraySize = 2000                   '2000 for 80 columns by 25
  481.                                      'rows.  Use 4000 for 80 x 50.
  482.  
  483.   IF FRE(-1) < ArraySize THEN        '... if there's not enough
  484.      Display.Screen = -88            '    memory, abort to caller
  485.      EXIT FUNCTION
  486.   END IF
  487.  
  488.   REDIM Array%(0 TO ArraySize)       '... BE SURE to dimension from element 0
  489.  
  490.   CALL rsLoadScrn(Array%(), LibName$, ScreenName$, Desc$, TopRow, LeftCol, BotRow, RhtCol, ScrnSize, ErrCode)
  491.  
  492.   '... If ErrCode is positive or 0, everything went ok.
  493.   IF ErrCode >= 0 THEN
  494.  
  495.      '... If the first element (0) returns NON-Zero, this is a bright-
  496.      '    background screen.  So CALL BrightBG if we haven't done so before.
  497.  
  498.      IF Array%(0) <> IsBrightOn% THEN
  499.         IsBrightOn% = Array%(0)          '...Note:  Calling BrightBG DOES
  500.         CALL BrightBG(Array%(0))         '   take time.  So let's do it ONLY
  501.      END IF                              '   when needed -- when the screen
  502.                                          '   we're displaying DIFFERS from
  503.                                          '   earlier ones:  Array%(0) <> IsBrightOn%
  504.  
  505.      '...registered users would use: : :
  506.      CALL CompRestPLUS(TopRow, LeftCol, BotRow, RhtCol, SEG Array%(1))
  507.  
  508.   ELSE
  509.      '... an error occurred; return it to the caller.
  510.      Display.Screen = ErrCode
  511.  
  512.   END IF
  513.  
  514.   '... clean up memory (we don't need the array any more)
  515.   ERASE Array
  516.  
  517. END FUNCTION
  518.  
  519. '................. .................  ................. .................
  520. SUB LoadMenus (MenuDemo%(), Menu.ErrCode)
  521. '................. .................  ................. .................
  522. '   Purpose:  1) Load ALL menu screens from P-Screen.Psl into our
  523. '                MenuDemo%() array for fast display later on.
  524. '             2) Demonstrate how to do this in your programs -- for those
  525. '                situations needing instant screens.
  526. '
  527. '     Calls:  Run only with LoadScrn.obj & rsLodBin.obj in your Quick Library
  528. '................. .................  ................. .................
  529. '... setup
  530. '................. .................  ................. .................
  531.     CLS
  532.   
  533.     REDIM MenuDemo%(1 TO 2000)  '... Less than 2000 bytes FAR memory needed to
  534.                                 '    store ALL menus.  Saves lots of string space.
  535.                                 '    In your programs, calculate (##) on the fly.
  536.                                 '    See commented-out sections below for how.
  537.  
  538.     REDIM Tmp%(1)               '... Temporary storage for each screen
  539.   
  540.   
  541.     Offset = 10                 '... Offset into MenuDemo% to load each new screen.
  542.                                 '    We have 9 screens. Elements 1-9 of MenuDemo%
  543.                                 '    store the offset of each screen for re-displaying.
  544.     ScreenNumber = 1            '    To store Offset for re-displaying screen.
  545.  
  546. '................. .................  ................. .................
  547. '... start loading "Menu" screens
  548. '................. .................  ................. .................
  549.  
  550.     ScrnN$ = "PSCRTOP1":      GOSUB CalcOffset
  551.   
  552.     ScrnN$ = "PSCRFILE":      GOSUB CalcOffset
  553.   
  554.     ScrnN$ = "PSCRDRAW":      GOSUB CalcOffset
  555.   
  556.     ScrnN$ = "PSCRBLOK":      GOSUB CalcOffset
  557.   
  558.     ScrnN$ = "PSCREDIT":      GOSUB CalcOffset
  559.  
  560.     ScrnN$ = "PSCROPTN":      GOSUB CalcOffset
  561.   
  562.     ScrnN$ = "PSCRHELP":      GOSUB CalcOffset
  563.   
  564.  
  565. '... UNComment next 2 lines (& line near end) if you want to see stats as screens are loaded
  566.   
  567. ''   PRINT : PRINT TAB(4); "Press a key . . .";
  568. ''   D$ = INPUT$(1)   'pause  '... see below, if you print stats, pause before exit
  569.  
  570. '................. .................  ................. .................
  571.  EXIT SUB            '... all done
  572. '................. .................  ................. .................
  573.  
  574. '................. .................  ................. .................
  575. CalcOffset:         '... this does the actual work:  find the right spot
  576.                     '    (Offset) for each new screen, copy screen to MenuDemo%,
  577.                     '    then store Offset in MenuDemo% for displaying
  578. '................. .................  ................. .................
  579. CALL rsLoadScrn(Tmp%(), LibraryName$, ScrnN$, Desc$, TopRow, LeftCol, BottomRow, RhtCol, ScrnSize, ErrCode)
  580.  
  581. IF ErrCode < 0 THEN Menu.ErrCode = -99: EXIT SUB
  582.  
  583.  
  584.     FOR x = 1 TO UBOUND(Tmp%)           '... Copy it into MenuDemo%
  585.  
  586.         IF x + Offset > UBOUND(MenuDemo%) THEN EXIT FOR   '... just in case
  587.  
  588.         MenuDemo%(Offset + x) = Tmp%(x)   '    NOTE: 1st screen begins at 11
  589.     NEXT                                '    (Offset+x  or 10+1)
  590.  
  591.     MenuDemo%(ScreenNumber) = Offset + 1  '... Save the beginning of each screen.
  592.                                         '    See MenuDemo to see how MenuDemo%(1-10) are used.
  593.    
  594.    
  595.     ScreenNumber = ScreenNumber + 1     '... bump it for the next screen
  596.  
  597.     Offset = Offset + ScrnSize          '... Adjust Offset MenuDemo% so next screen
  598.                                         '    is stored after this one.
  599.  
  600. '... NOTE: UNComment next line (& Pause above) if you want to see stats as screens are loaded
  601.  
  602. ''   PRINT USING " \       \ Size:####  Ends:#####    Top Row/Col  ## ##,   Bottom Row/Col  ## ##"; ScrnN$; ScrnSize; Offset; TopRow; LeftCol; BottomRow; RhtCol
  603.  
  604. RETURN
  605. '................. .................  ................. .................
  606.  
  607. END SUB
  608.  
  609.